{extend name="public/common"} {block name="body"}
<title>基本设置</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    系统管理
    <span class="c-gray en">&gt;</span>
    财务设置
    <span class="c-gray en">&gt;</span>
    充值支付方案
    <span class="c-gray en">&gt;</span>
    支付类型
    <span class="c-gray en">&gt;</span>
    {if($type==0)}第三方支付{/if}
    {if($type==1)}线上支付{/if}
    {if($type==2)}线下支付{/if}
    <a class="btn btn-success radius r"
       style="line-height: 1.6em; margin-top: 3px"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>

<div class="page-container  dataTables_wrapper">
    <div style="padding:10px 0;height:30px;margin-top:10px;">
        <div style="float:left;margin-left:20px;">
            <a class="btn btn-primary radius" {if($type==2)}style="background:blue;"{/if}  href="{:url('paysetting/methodList')}?type=2&id={$id}">线下支付</a>
            <a class="btn btn-primary radius" {if($type==0)}style="background:blue;"{/if}  href="{:url('paysetting/methodList')}?type=0&id={$id}">第三方支付</a>
            <!--<a class="btn btn-primary radius" {if($type==1)}style="background:blue;"{/if}  href="{:url('paysetting/methodList')}?type=1&id={$id}">第四方支付</a>-->
        </div>
    </div>
    <div id="tab-system" class="HuiTab">
        <div class="tabCon">
            <div class="mt-20">
                <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
                    <thead>
                    <tr class="text-c">
                        {if(0==$type)}
                            <th>第三方名称</th>
                        {elseif(1==$type)}
                            <th>第四方名称</th>
                        {else/}
                            <th>线下名称</th>
                        {/if}

                        {if(0==$type)}
                        <th>支付方式</th>
                        {elseif(1==$type)}
                        <th>账号名称</th>
                        {else/}
                        <th>账号名称</th>
                        <th>二维码/卡号</th>
                        {/if}
                        {if(0==$type || 1==$type)}
                        <th>等级权限</th>
                        {/if}

                        {if(0==$type)}
                        <th>显示开关</th>
                        {else/}
                        <th>开关</th>
                        {/if}

                    </tr>
                    </thead>
                    <tbody>
                    {volist name="query" id="item"}
                    <tr class="text-c">
                        <td>{$item.name_2}</td>

                        {if(0==$type || 1==$type)}
                        <td>{$item.name_1}</td>
                        {else/}
                        <th>{$item.name_1}</th>
                        <th>
                            {if($item['xx_weixin']=='0' && $item['xx_zhifubao']=='0' && $item['xx_qq']=='0' && $item['xx_wangyin']=='1')}
                                {$item.xx_bankno}
                            {else/}
                            <img style="height: 40px;" src="../../static/attachment/{$item.xx_erweima}">
                            {/if}
                        </th>
                        {/if}

                        {if(0==$type || 1==$type)}
                        <td><a href="javascript:;" onclick="Jurisdiction('等级权限','{:url('paysetting/jurisdiction')}?id={$item.pid}')"> <i class="Hui-iconfont">&#xe62e;</i></a></td>
                        {/if}

                        {if(0==$type)}
                        <td>
                            <input type="checkbox" name="pc" {if($item.pc)}checked="checked"{/if} onchange="updateSupport(this.name,{$item.id},this.checked)" />电脑端
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="checkbox" name="mob" {if($item.mob)}checked="checked" }{/if} onchange="updateSupport(this.name,{$item.id},this.checked)" />手机端
                        </td>
                        {elseif(1==$type)/}
                        <td>
                            <span >{$item['lock']==0?'已开启':'已关闭'}</span>&nbsp;&nbsp;&nbsp;&nbsp;
                            <a style="color:red;cursor:pointer;width:25px;background-color: #cccccc;padding:0 5px;border-radius: 5px;" class="open" id="open_{$item.id}">{if($item['lock']==0)}关{else/}开{/if}</a>
                        </td>
                        {elseif(2==$type)/}
                        <td>
                            <span >{$item['status']==1?'已开启':'已关闭'}</span>&nbsp;&nbsp;&nbsp;&nbsp;
                            <a style="color:red;cursor:pointer;width:25px;background-color: #cccccc;padding:0 5px;border-radius: 5px;" class="open_off" data-id="{$item.id}" data-status="{$item['status']}">{if($item['status']==1)}关{else/}开{/if}</a>
                        </td>
                        {/if}
                    </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="dataTables_paginate paging_simple_numbers" style="width:100%;">
        <span style="float:right;margin-left:-2px;">总共{$query->lastPage()}页  当前第{$query->currentPage()}页 ，共{$query->total()}条</span>
        <div style="float:left;">{$query->render()}</div>
    </div>
</div>
{/block}

{block name="js"}
<script type="text/javascript" src="__SYSMET__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript">
    $(function() {
        $('.skin-minimal input').iCheck({
            checkboxClass : 'icheckbox-blue',
            radioClass : 'iradio-blue',
            increaseArea : '20%'
        });
        $("#tab-system").Huitab({
            index : 0
        });
    });

</script>
<script>
    function updateSupport(name,id,checked) {
        $.ajax({
            type : "post",
            url : "{:url('paysetting/updateSupport')}",
            data : {"name":name,"id":id,"status":checked},
            success: function (data) {
                if( 1==parseInt(data) ){
                    layer.msg('更新成功', {icon: 1});
                }else{
                    layer.msg('更新失败', {icon: 5});
                }
            }
        });
    }
    $(".open").click(function(){
        var open = $(this).attr('id');
        var status = $("#"+open).html();
        var tid = open.substr(5);
        $.ajax({
            type : "post",
            url : "{:url('paysetting/updateOnLineStatus')}",
            data : {"open":status,"uid":tid},
            success: function (data) {
                if(data=='1') {
                    if(status=='开'){
                        $("#"+open).html('关');
                        $("#"+open).prev().html('已开启');
//                         location.replace(location.href);
                    }else{
                        $("#"+open).html('开');
                        $("#"+open).prev().html('已关闭');
//                         location.replace(location.href);
                    }
                } else {
                    layer.msg('更新失败', {icon: 5});
                    return false;
                }
            }
        });
    });
    $('.open_off').click(function(){
        var status = $(this).data('status');
        var id = $(this).data('id');
        var obj = this;
        $.ajax({
            type : "post",
            url : "{:url('paysetting/updateOff')}",
            data : {"id":id,"status":status},
            success: function (data) {
                if( 1==parseInt(data)) {
                    if( status == 1 ){
                        $(obj).html('关');
                        $(obj).data('status',0);
                        $(obj).prev().html('已开启');
//                         location.replace(location.href);
                    }else{
                        $(obj).html('开');
                        $(obj).data('status',1);
                        $(obj).prev().html('已关闭');
//                         location.replace(location.href);
                    }
                } else {
                    layer.msg('更新失败', {icon: 5});
                    return false;
                }
            }
        });
    });
    function Jurisdiction(title,url,w,h){
        layer_show(title,url,w,500);
    }
</script>
{/block}
